<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
	  xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">  

<h:head>

	<link rel="StyleSheet" type="text/css" href="css/sistema.css" media="screen" />

	<style>
		.ui-panelgrid, .ui-panelgrid td
		{
			font-size:12px !important;
			border-style:none !important;
			border-collapse:separate;
		} 
	</style>
</h:head> 

<body>
<!-- Comenteario Do THIAGO 	
	<f:metadata>
		<f:viewParam name="id" value="#{sistemaMB.id}"></f:viewParam>
		<f:event listener="#{sistemaMB.init()}" type="preRenderView" />
	</f:metadata>
 -->
  	<f:metadata>
  		<f:event type="preRenderView" listener="#{sistemaMB.mostraSistema()}"/>
  	</f:metadata>
  	
  	<h:graphicImage value="./resoursers/imagens/capgov.png" styleClass="imagem"/>
  	
	<p:panel style="font-size:14px;">
 		<p:menubar style="font-size:14px; border: none !important; height: 40px; background-color: transparent !important">    
			<p:submenu label="INICIO" icon="ui-icon-home"> 
				<p:menuitem value="SISTEMAS" url="http://localhost:8080/treinamento-web/sistema.xhtml" icon="ui-icon-arrowreturnthick-1-w" />					            
			</p:submenu>  
					   
			<p:submenu label="CONTROLE" icon="ui-icon-pencil">  
				<p:menuitem value="ANDAMENTO" url="http://localhost:8080/treinamento-web/controlaSistema.xhtml" icon="ui-icon-arrowreturnthick-1-w" />  
			</p:submenu> 
        </p:menubar>
			
		<p:growl id="growl" showDetail="true" sticky="false"/>	
			<h:form id="form">
				<p:fieldset legend="Projetos" style="font-size:14px"> 
									
					<p:panelGrid columns="4" style="border-style:none">
						<p:outputLabel value="Digite o Nome do Sistema: " for="nomeSistema" style="font-size:15px"/>
						<p:inputText value="#{sistemaMB.sistema.nomeSistema}" id="nomeSistema" style="width:450px" required="true" requiredMessage="Nome obrigatório."/>
						<p:watermark for="nomeSistema" value="Digite o nome do Sistema"></p:watermark>		
    						<p:column>
    							<p:outputLabel value="Verificar este Sistema: "/>
        						<p:selectBooleanCheckbox  value="#{sistemaMB.sistema.verificar}"/> 
    						</p:column>
						<p:outputLabel value="Digite a(s) URL(s): " for="url" style="font-size:15px"/>
						<p:inputText value="#{sistemaMB.url.nomeUrl}" id="url"  style="width:450px;"/>
						<p:watermark for="url" value="Digite a Url do Sistema"></p:watermark>	
							<p:commandLink actionListener="#{sistemaMB.adicionarListaUrl()}" title="Adiciona URL Sistema" update=":form :growl">									  
								<img src="./resoursers/imagens/adicionar.png" style="height:18px;"/>
							</p:commandLink>		
					</p:panelGrid>
					
					<p:panel style="margin-top:20px; width:50%">
					
						<p:dataTable  id="TbUrl" value="#{sistemaMB.urls}" var="url" style="font-size:15px; width:100%" emptyMessage="Url não atualizada">
							<p:column headerText="URLS P/ Salvar"  style="width:100%">
								#{url.nomeUrl}	
							</p:column>													
							<p:column headerText="Remover" style="width:10%">
								<p:commandLink actionListener="#{sistemaMB.removeUrl(url.nomeUrl)}" title="Remover URL" update="@form :growl">									  
									<center><img src="./resoursers/imagens/remover.png" style="height:18px;"/></center>
								</p:commandLink>
							</p:column>
						</p:dataTable>
							
						<p:dataTable  id="TbUrlBD" value="#{sistemaMB.urlsBD}" var="url" style="font-size:15px; width:100%" emptyMessage="Url não atualizada">
							<p:column headerText=" URLS Salvas " style="width:100%">
								#{url.nomeUrl}	
							</p:column>	
							<p:column width="15" headerText=" Alterar ">
								<p:commandLink actionListener="#{sistemaMB.carregaUrl(url.id)}" title="Alterar Sistema" update=":form :growl">									  
									<center><img src="./resoursers/imagens/detalhe.png" style="height:18px;"/></center>
								</p:commandLink>				
							</p:column>												
							<p:column  headerText="Remover" style="width:10%">
								<p:commandLink oncomplete="confirmaExclusaoUrl.show()" title="Remover Url">									  
									<f:setPropertyActionListener value="#{sistemaMB.preparaRemocaoDaUrl(url)}" target="#{url}" update="@form :growl"/>
										<center><img src="./resoursers/imagens/remover.png" style="height:18px;"/></center>
								</p:commandLink>
							</p:column>
						</p:dataTable>						
					</p:panel>			
						<p:commandButton value="Novo"  action="#{sistemaMB.novoSistema()}" update=":form" style="margin-top:10px; font-size:13px; padding:3px 3px 3px 3px;"/>
						<p:commandButton value="Salvar" action="#{sistemaMB.salvar()}" update=":form :form2 :growl" style="margin-top:10px; margin-left:10px; font-size:13px; padding:3px 3px 3px 3px;"/>						
				</p:fieldset>	
			</h:form>			
	</p:panel>	

		<h:form id="form2">
			<p:panel style="margin-top:20px; width:70%">
				<p:outputLabel value="Sistemas: " for="autoComplete"/>
				<p:autoComplete id="autoComplete" value="#{sistemaMB.sistemaInserir}" completeMethod="#{sistemaMB.listarSugestoes}" maxResults="10" minQueryLength="2"/><br/><br/>
				<p:dataTable value="#{sistemaMB.sistemas}" var="sistema" style="font-size:15px; width:100%" emptyMessage="Nenhum Sistema encontrado">
					<p:column headerText="Sistema">
						#{sistema.nomeSistema}	
					</p:column>
					<p:column width="15" headerText=" Alterar ">
						<p:commandLink actionListener="#{sistemaMB.carregaSistema(sistema.id)}" title="Alterar Sistema" update=":form :growl">									  
							<center><img src="./resoursers/imagens/detalhe.png" style="height:18px;"/></center>
						</p:commandLink>				
					</p:column>
					<p:column headerText="Remover" style="font-size:15px;  width:15%">
						<p:commandLink oncomplete="confirmaExclusaoSistema.show()" title="Remover Sistema">
							<f:setPropertyActionListener value="#{sistemaMB.preparaRemocaoDoSistema(sistema)}" target="#{sistema}" update="@form :growl"/>    
  								<center><img src="./resoursers/imagens/remover.png" style="height:18px;"/></center>
  						</p:commandLink>
  					</p:column>
  				</p:dataTable>
  				
				<p:confirmDialog id="confirmaExclusaoSistema" message="Deseja realmente excluir?" modal="true" header="Atenção!" severity="alert" widgetVar="confirmaExclusaoSistema">    
                    <center><p:commandButton id="confirmaAcaoSistema" value="Sim" oncomplete="confirmaExclusaoSistema.hide()" action="#{sistemaMB.confirmaRemocaoDoSistema()}" ajax="false" onclick="confirmaEsclusaoSistema.hide()" update="@form :growl"/>  
  					<p:commandButton id="recusaAcaoSistema" value="Não" onclick="confirmaExclusaoSistema.hide()"/></center>     
				</p:confirmDialog>
				<p:confirmDialog id="confirmaExclusaoUrl" message="Deseja realmente excluir?" modal="true" header="Atenção!" severity="alert" widgetVar="confirmaExclusaoUrl">
					<center><p:commandButton id="confirmaAcaoUrl" value="Sim" oncomplete="confirmaExclusaoUrl.hide()" action="#{sistemaMB.confirmaRemocaoDaUrl()}" ajax="false" onclick="confirmaEsclusaoUrl.hide()" update="@form :growl"/>
					<p:commandButton id="recusaAcaoUrl" value="Não" onclick="confirmaExclusaoUrl.hide()"/></center>
				</p:confirmDialog>
			</p:panel>	
		</h:form>				
</body> 
</html>